#!/bin/bash
#一旦某行出错则停止

version=$V_SERVER

set -e
config="./modules/$2/variable_$1.properties"
template="./template.yaml"
destination="./target/$2/config/fu-$1.yaml"

cp "$template" "$destination"

while read line || [[ -n ${line} ]]; do
	setting="$( echo "$line" | cut -d '=' -f 1 )"
	value="$( echo "$line" | cut -d '=' -f 2- )"

  if [[ $setting == 'VERSION' ]]
  then
    value=$version
  fi

	sed -i -e "s;%${setting}%;${value};g" "$destination"
done < "$config"
